﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MachineVision.Core.Util
{
    /// <summary>
    /// 响应结果
    /// </summary>
    public class ResponseResult<T>
    {
        /// <summary>
        /// 响应状态
        /// </summary>
        private ResultCode Code;

        /// <summary>
        /// 消息
        /// </summary>
        private string Message;

        /// <summary>
        /// 存储数据
        /// </summary>
        private T Data;



        /// <summary>
        /// 成功
        /// </summary>
        /// <returns></returns>
        public static ResponseResult<T> Success()
        {
            return new ResponseResult<T>
            {
                Code = ResultCode.Success,
                Message = "成功"
            };
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <returns></returns>
        public static ResponseResult<T> Success(T data)
        {
            return new ResponseResult<T>
            {
                Code = ResultCode.Success,
                Message = "成功",
                Data = data
            };
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <returns></returns>
        public static ResponseResult<T> Success(T data, string message)
        {
            return new ResponseResult<T>
            {
                Code = ResultCode.Success,
                Message = message,
                Data = data
            };
        }


        /// <summary>
        /// 失败
        /// </summary>
        /// <returns></returns>
        public static ResponseResult<T> Error()
        {
            return new ResponseResult<T>
            {
                Code = ResultCode.Error,
                Message = "失败"
            };
        }

        /// <summary>
        /// 失败
        /// </summary>
        /// <returns></returns>
        public static ResponseResult<T> Error(string message)
        {
            return new ResponseResult<T>
            {
                Code = ResultCode.Error,
                Message = message
            };
        }
    }
}
